//
//  UIConfig.h
//  SoupApp
//
//  Created by pro2 on 2018/11/1.
//  Copyright © 2018 pro2. All rights reserved.
//

#ifndef UIConfig_h
#define UIConfig_h

#define weakify(var) __weak typeof(var) XYWeak_##var = var;
#define strongify(var) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wshadow\"") \
__strong typeof(var) var = XYWeak_##var; \
_Pragma("clang diagnostic pop")

#undef    AS_SINGLETON
#define AS_SINGLETON(class) \
+ (instancetype)sharedInstance; \
+ (void)distroyInstance;


#undef    DEF_SINGLETON
#define DEF_SINGLETON(class) \
static class *sharedInstance##class; \
+ (instancetype)sharedInstance { \
@synchronized (self) { \
if (sharedInstance##class == nil) { \
sharedInstance##class = [[self alloc] init]; \
} \
} \
return sharedInstance##class; \
} \
+ (void)distroyInstance { \
@synchronized (self) { \
sharedInstance##class = nil; \
} \
}

//颜色宏定义
#define RGB(r, g, b)             [UIColor colorWithRed:((r) / 255.0) green:((g) / 255.0) blue:((b) / 255.0) alpha:1.0]
#define RGBAlpha(r, g, b, a)     [UIColor colorWithRed:((r) / 255.0) green:((g) / 255.0) blue:((b) / 255.0) alpha:(a)]
#define RGBHex(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
#define RGBHexAlpha(rgbValue,a) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:(a)]

//平方字体 ---- 粗体
#define UIFontMediumMake(font) [UIFont fontWithName:@"PingFangSC-Medium"size:font]
//平方字体 ---- 细体
#define UIFontRegularMake(font) [UIFont fontWithName:@"PingFangSC-Regular"size:font]

#define UserFont(name,type,size) [AddImageView customFontWithLocationName:name fileType:type fontSize:size]

// manager
#define CLIENT                  [HAClient sharedInstance]
#define APPDELEGATE             (AppDelegate *)[UIApplication sharedApplication].delegate
#define UserDefaults            [NSUserDefaults standardUserDefaults]
#define CONTENTMANAGER          [ContentManager sharedInstance]
#define PAGEGUIDEMANAGER        [PageGuideManager sharedInstance]  


//字符串是否为空
#define StringIsEmpty(str) ([str isKindOfClass:[NSNull class]] || str == nil || [str length] < 1 ? YES : NO )
//数组是否为空
#define ArrayIsEmpty(array) (array == nil || [array isKindOfClass:[NSNull class]] || array.count == 0)
//字典是否为空
#define DictIsEmpty(dic) (dic == nil || [dic isKindOfClass:[NSNull class]] || dic.allKeys == 0)
//是否是空对象
#define ObjectIsEmpty(_object) (_object == nil \
|| [_object isKindOfClass:[NSNull class]] \
|| ([_object respondsToSelector:@selector(length)] && [(NSData *)_object length] == 0) \
|| ([_object respondsToSelector:@selector(count)] && [(NSArray *)_object count] == 0))

//private
#define BASEURL @"http://m.yumengtongkj.com/"
#define SIGNKEY @"DAS42DDB8-CX8JGB8XZ-8CTSOJDL"
#define YINSIURL @"http://m.yumengtongkj.com"
#define GUANYUURL @"http://m.yumengtongkj.com/index/index/about"



#endif /* UIConfig_h */
